reconnecting-jsonrpsee-ws-client
Wrapper crate over the jsonrpsee ws client, which automatically reconnects
under the hood; without that, one has to restart it.
It supports a few retry strategies, such as exponential backoff, but it's also possible
to use custom strategies as long as it implements Iterator<Item = Duration>
.
By default, the library is re-transmitting pending calls and re-establishing subscriptions that were closed when the connection was terminated, but it's also possible to disable that and manage it yourself.
For instance, you may not want to re-subscribe to a subscription
that has side effects or retries at all. Then the library exposes
request_with_policy
and subscribe_with_policy
to support that
let mut sub = client
.subscribe_with_policy
.await
.unwrap;
The tricky part is subscriptions, which may lose a few notifications when it's re-connecting, it's not possible to know which ones.
Lost subscription notifications may be very important to know in some cases, and then this library is not recommended to use.
There is one way to determine how long a reconnection takes:
// Print when the RPC client starts to reconnect.
loop
Example
use ;
use Duration;
async